<template>
  <div class="side-nav">
    <div class="side-nav-header">
      <h3 class="nav-title">{{ title }}</h3>
    </div>
    <div class="side-nav-content">
      <button 
        v-for="tab in tabs" 
        :key="tab.key" 
        class="nav-item"
        :class="{ active: activeTab === tab.key }"
        @click="handleTabClick(tab)"
      >
        <span class="nav-icon" v-if="tab.icon">{{ tab.icon }}</span>
        <span class="nav-text">{{ tab.name }}</span>
        <span v-if="tab.badge" class="nav-badge">{{ tab.badge }}</span>
      </button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'SideNav',
  props: {
    title: {
      type: String,
      required: true
    },
    tabs: {
      type: Array,
      required: true
    },
    activeTab: {
      type: String,
      required: true
    }
  },
  methods: {
    handleTabClick(tab) {
      this.$emit('tab-click', tab.key)
    }
  }
}
</script>

<style scoped>
.side-nav {
  width: 240px;
  background: #fff;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  overflow-y: auto;
}

.side-nav-header {
  padding: 20px 20px 15px;
  border-bottom: 1px solid #f0f0f0;
}

.nav-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.side-nav-content {
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  font-size: 16px;
}

.nav-item:hover {
  background: #f5f5f5;
  color: #2ed573;
}

.nav-item.active {
  background: #f0f9ff;
  color: #2ed573;
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #2ed573;
}

.nav-icon {
  margin-right: 10px;
  font-size: 18px;
}

.nav-text {
  flex: 1;
}

.nav-badge {
  background: #ff4757;
  color: #fff;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
</style>